const db = require("../../../db");

const update = (req, res) => {
  let { nickname, avatar, gender, email, qq, userId } = req.body;
  let sql = `update user set nickname='${nickname}', avatar='${avatar}', gender='${gender}', email='${email}', qq='${qq}' where id='${userId}'`;
  db.query(sql, (err, result) => {
    if (err) return res.send({ code: 2, message: err.message });
    if (result.affectedRows) {
      res.send({ code: 0, message: "更新成功" });
    } else {
      res.send({ code: 1, message: "更新失败" });
    }
  });
};

module.exports = update;
